//文件的写操作5
import java.io.*;
public class Demo17 {
    public static void main(String[] args) throws IOException{
        //new FileOutputStream("hello7.txt",true)表示以追加模式打开文件
        //如果文件不存在，则创建文件
        //如果文件存在，则在文件末尾追加内容
        try(OutputStream out = new FileOutputStream("hello7.txt",true)){ 
            try(OutputStreamWriter writer = new OutputStreamWriter(out,"utf-8")){
                try(PrintWriter pw = new PrintWriter(writer)){ //PrintWriter可以方便地打印各种数据类型
                    pw.println("H"); 
                    pw.println("H"); 
                    pw.println("H"); 
                    pw.println("H"); 
                    pw.println("H"); 
                    pw.println("H"); 
                    pw.flush(); //千万不要忘记flush
                }
            }
        }
    }
}
